package com.jczy.cyclone.mmkv

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import com.jczy.lib_utils.mmkv.MMKVOwner
import com.jczy.lib_utils.mmkv.MMKVProperty
import com.tencent.mmkv.MMKV

/**
 *@author Wcj
 *@description 存储token
 *@date 2022/8/24 16:44
 */
object AuthMMKV : MMKVOwner {

    override val mmkv: MMKV
        get() = MMKV.mmkvWithID(MMKVConfig.ID.AUTH)

    //token
    var accessToken by MMKVProperty("")


    //目前token暂未互通
    //var openApiAccessToken by MMKVProperty("22101916523407B40101")
    //var openApiSecretToken by MMKVProperty("864e70ef0b8f95d6ea7b679f91808135")
    //登录key
//    var openApiAccessToken by MMKVProperty("23022113430907CF0113#0")
//    var openApiSecretToken by MMKVProperty("502d767edfc6085084b88b3a24c69026")
    //目前token暂未互通
    //访问key和 PARTNER_ID 一样 放在header里
    var openApiAccessKey by MMKVProperty("23022113430907CF0113")

    // token
    //var openApiAccessToken by MMKVProperty("eyJhbGciOiJIUzUxMiJ9.eyJyZWZyZXNoX251bSI6MywidG9rZW5BcHBJZCI6IjIzMDIyMTEzNDMwOTA3Q0YwMTEzIiwidG9rZW5Vc2VySWQiOjE0NzkyNTY1MzQxNjI3OTI0NjksImNyZWF0ZSI6MTY4MTAwOTM1MTczOSwidG9rZW5Vc2VyTmFtZSI6IuaRqeWPi2ZsY3gxbyIsImV4cCI6MTY4MjI2MDk4NiwidG9rZW5Vc2VyQ29kZSI6IjE2ODA2MTg2MjkifQ.OyZHMi7LOi851xmlJl_SeUFEhLOYUnSetTakROWAD4Cj-wTKlU41QBX5up_4JUFKPcHIJkL6nhRJini9u8U8bw")
    //var openApiAccessToken by MMKVProperty("eyJhbGciOiJIUzUxMiJ9.eyJyZWZyZXNoX251bSI6MywidG9rZW5BcHBJZCI6IjIzMDIyMTEzNDMwOTA3Q0YwMTEzIiwidG9rZW5Vc2VySWQiOjE0NzkyNTY1MzQxNjI3OTI0OTUsImNyZWF0ZSI6MTY4MTM3NTI5NDAwMSwidG9rZW5Vc2VyTmFtZSI6IuaRqeWPi29heG9hYSIsImV4cCI6MTY4MjYyNjkyOSwidG9rZW5Vc2VyQ29kZSI6IjE2ODEwOTYyMTAifQ.Gfow_Rx3n9PL5WDgXhfsqI_Xxxw3pPwlsF-3MCdsuQ42hgcA2ayraQi-yLua6Hd3kf8SVJA3jSKJluXPejkotA")
    val openApiAccessToken
        get() = accessToken

    //加密key 用于请求体加密
    var openApiSecretKey by MMKVProperty("6eef7179f83aea3986f7dd9be4c5cd8a")

    // 已登录
    fun hasLogin() = accessToken.isNotEmpty()

    /*需求修改，去掉所有的toast“请登录”，直接弹登录页面*/
//    fun hasLoginWithToast(context: Context, autoJumpLogin: Boolean = true): Boolean {
//        if (hasLogin())
//            return true
//        //ToastUtils.showLong(context, "请先登录")
//        if (autoJumpLogin)
//            ARouterUtils.jumpLogin(context as? AppCompatActivity)
//        return false
//    }
}